/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Janelas;


import javax.swing.JOptionPane;
import persistencia.*;
import java.awt.Component;
import java.awt.Container;
import excecoes.PasswordsDontMatchException;
import excecoes.UserNotFoundException;
import javax.swing.JPanel;

public class Principal extends javax.swing.JFrame {
private CadastroVeiculos cadastrarVeiculo;
private CadastroCliente cadastrarCliente;
private CadastroFuncionario cadastrarFuncionario;
private CadastroDevolucao cadastrarDevolucao;
private CadastroLocacao cadastrarLocacao;
private CadastroMotorista cadastrarMotorista;
private ConsultaVeiculo consultarVeiculo;
private ConsultaFuncionario consultarFuncionario;
    /** Creates new form Principal */
    public Principal() {
        cadastrarVeiculo = new CadastroVeiculos();
        cadastrarCliente = new CadastroCliente();
        cadastrarFuncionario = new CadastroFuncionario();
        cadastrarDevolucao = new CadastroDevolucao();
        cadastrarLocacao = new CadastroLocacao();
        cadastrarMotorista = new CadastroMotorista();
        consultarVeiculo = new ConsultaVeiculo();
        consultarFuncionario = new ConsultaFuncionario();
        initComponents();
        inicial();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelLogin = new javax.swing.JPanel();
        LoginRotuloUsuario = new javax.swing.JLabel();
        LoginCampoUsuario = new javax.swing.JTextField();
        LoginRotuloSenha = new javax.swing.JLabel();
        LoginBotaoLogin = new javax.swing.JButton();
        LoginCampoSenha = new javax.swing.JPasswordField();
        LoginBotaoCancelar = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu4 = new javax.swing.JMenu();
        menuLogar = new javax.swing.JMenuItem();
        menuAlterarSenha = new javax.swing.JMenuItem();
        menuSair = new javax.swing.JMenuItem();
        menuCadastro = new javax.swing.JMenu();
        menuCadastroVeiculo = new javax.swing.JMenuItem();
        menuCadastroCliente = new javax.swing.JMenuItem();
        menuCadastroLocacao = new javax.swing.JMenuItem();
        menuCadastroFuncionario = new javax.swing.JMenuItem();
        menuCadastroMotorista = new javax.swing.JMenuItem();
        menuCadastroDevolucao = new javax.swing.JMenuItem();
        menuConsulta = new javax.swing.JMenu();
        menuConsultaLocacao = new javax.swing.JMenu();
        menuConsultaLocacaoAberto = new javax.swing.JMenuItem();
        menuConsultaLocacaoFinalizado = new javax.swing.JMenuItem();
        menuConsultaVeiculo = new javax.swing.JMenu();
        menuConsultaVeiculoDisponivel = new javax.swing.JMenuItem();
        menuConsultaVeiculoProcurados = new javax.swing.JMenuItem();
        menuConsultaVeiculoRentavel = new javax.swing.JMenuItem();
        menuConsultaCliente = new javax.swing.JMenuItem();
        menuConsultaFuncionario = new javax.swing.JMenuItem();
        menuExcluir = new javax.swing.JMenu();
        jMenuItem20 = new javax.swing.JMenuItem();
        menuExcluirLocacao = new javax.swing.JMenuItem();
        menuExcluirMotorista = new javax.swing.JMenuItem();
        menuExcluirVeiculo = new javax.swing.JMenuItem();
        menuExcluirFuncionario = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        painelLogin.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Login", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 12))); // NOI18N

        LoginRotuloUsuario.setText("Nome de usuário");

        LoginCampoUsuario.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        LoginRotuloSenha.setText("Senha");

        LoginBotaoLogin.setBackground(java.awt.Color.gray);
        LoginBotaoLogin.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        LoginBotaoLogin.setText("Login");
        LoginBotaoLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginBotaoLoginActionPerformed(evt);
            }
        });

        LoginBotaoCancelar.setBackground(java.awt.Color.lightGray);
        LoginBotaoCancelar.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        LoginBotaoCancelar.setText("Cancelar");
        LoginBotaoCancelar.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        LoginBotaoCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginBotaoCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout painelLoginLayout = new javax.swing.GroupLayout(painelLogin);
        painelLogin.setLayout(painelLoginLayout);
        painelLoginLayout.setHorizontalGroup(
            painelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelLoginLayout.createSequentialGroup()
                .addGroup(painelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelLoginLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LoginCampoUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelLoginLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LoginCampoSenha, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelLoginLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LoginRotuloUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelLoginLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LoginRotuloSenha))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelLoginLayout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(LoginBotaoLogin)
                        .addGap(18, 18, 18)
                        .addComponent(LoginBotaoCancelar)))
                .addGap(253, 253, 253))
        );
        painelLoginLayout.setVerticalGroup(
            painelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelLoginLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LoginRotuloUsuario)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LoginCampoUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(LoginRotuloSenha)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LoginCampoSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(painelLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LoginBotaoLogin)
                    .addComponent(LoginBotaoCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(120, Short.MAX_VALUE))
        );

        jMenu4.setText("Login");

        menuLogar.setForeground(java.awt.Color.black);
        menuLogar.setText("Logar");
        menuLogar.setContentAreaFilled(false);
        menuLogar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuLogarActionPerformed(evt);
            }
        });
        jMenu4.add(menuLogar);

        menuAlterarSenha.setForeground(java.awt.Color.black);
        menuAlterarSenha.setText("Alterar senha");
        menuAlterarSenha.setContentAreaFilled(false);
        menuAlterarSenha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuAlterarSenhaActionPerformed(evt);
            }
        });
        jMenu4.add(menuAlterarSenha);

        menuSair.setForeground(java.awt.Color.black);
        menuSair.setText("Sair");
        menuSair.setContentAreaFilled(false);
        menuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSairActionPerformed(evt);
            }
        });
        jMenu4.add(menuSair);

        jMenuBar1.add(jMenu4);

        menuCadastro.setText("Cadastro");

        menuCadastroVeiculo.setForeground(java.awt.Color.black);
        menuCadastroVeiculo.setText("Veículo");
        menuCadastroVeiculo.setContentAreaFilled(false);
        menuCadastroVeiculo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastroVeiculoActionPerformed(evt);
            }
        });
        menuCadastro.add(menuCadastroVeiculo);

        menuCadastroCliente.setForeground(java.awt.Color.black);
        menuCadastroCliente.setText("Cliente");
        menuCadastroCliente.setContentAreaFilled(false);
        menuCadastroCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastroClienteActionPerformed(evt);
            }
        });
        menuCadastro.add(menuCadastroCliente);

        menuCadastroLocacao.setForeground(java.awt.Color.black);
        menuCadastroLocacao.setText("Locação");
        menuCadastroLocacao.setContentAreaFilled(false);
        menuCadastroLocacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastroLocacaoActionPerformed(evt);
            }
        });
        menuCadastro.add(menuCadastroLocacao);

        menuCadastroFuncionario.setForeground(java.awt.Color.black);
        menuCadastroFuncionario.setText("Funcionário");
        menuCadastroFuncionario.setContentAreaFilled(false);
        menuCadastroFuncionario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastroFuncionarioActionPerformed(evt);
            }
        });
        menuCadastro.add(menuCadastroFuncionario);

        menuCadastroMotorista.setForeground(java.awt.Color.black);
        menuCadastroMotorista.setText("Motorista");
        menuCadastroMotorista.setContentAreaFilled(false);
        menuCadastroMotorista.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastroMotoristaActionPerformed(evt);
            }
        });
        menuCadastro.add(menuCadastroMotorista);

        menuCadastroDevolucao.setForeground(java.awt.Color.black);
        menuCadastroDevolucao.setText("Devolução");
        menuCadastroDevolucao.setContentAreaFilled(false);
        menuCadastroDevolucao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastroDevolucaoActionPerformed(evt);
            }
        });
        menuCadastro.add(menuCadastroDevolucao);

        jMenuBar1.add(menuCadastro);

        menuConsulta.setText("Consulta");

        menuConsultaLocacao.setForeground(java.awt.Color.black);
        menuConsultaLocacao.setText("Locação");
        menuConsultaLocacao.setContentAreaFilled(false);

        menuConsultaLocacaoAberto.setForeground(java.awt.Color.black);
        menuConsultaLocacaoAberto.setText("em aberto");
        menuConsultaLocacaoAberto.setContentAreaFilled(false);
        menuConsultaLocacao.add(menuConsultaLocacaoAberto);

        menuConsultaLocacaoFinalizado.setForeground(java.awt.Color.black);
        menuConsultaLocacaoFinalizado.setText("finalizado");
        menuConsultaLocacaoFinalizado.setContentAreaFilled(false);
        menuConsultaLocacao.add(menuConsultaLocacaoFinalizado);

        menuConsulta.add(menuConsultaLocacao);

        menuConsultaVeiculo.setForeground(java.awt.Color.black);
        menuConsultaVeiculo.setText("Veículos");
        menuConsultaVeiculo.setContentAreaFilled(false);
        menuConsultaVeiculo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultaVeiculoActionPerformed(evt);
            }
        });

        menuConsultaVeiculoDisponivel.setForeground(java.awt.Color.black);
        menuConsultaVeiculoDisponivel.setText("disponíveis");
        menuConsultaVeiculoDisponivel.setContentAreaFilled(false);
        menuConsultaVeiculo.add(menuConsultaVeiculoDisponivel);

        menuConsultaVeiculoProcurados.setForeground(java.awt.Color.black);
        menuConsultaVeiculoProcurados.setText("mais procurados");
        menuConsultaVeiculoProcurados.setContentAreaFilled(false);
        menuConsultaVeiculo.add(menuConsultaVeiculoProcurados);

        menuConsultaVeiculoRentavel.setForeground(java.awt.Color.black);
        menuConsultaVeiculoRentavel.setText("mais rentáveis");
        menuConsultaVeiculoRentavel.setContentAreaFilled(false);
        menuConsultaVeiculo.add(menuConsultaVeiculoRentavel);

        menuConsulta.add(menuConsultaVeiculo);

        menuConsultaCliente.setForeground(java.awt.Color.black);
        menuConsultaCliente.setText("Cliente");
        menuConsultaCliente.setContentAreaFilled(false);
        menuConsulta.add(menuConsultaCliente);

        menuConsultaFuncionario.setForeground(java.awt.Color.black);
        menuConsultaFuncionario.setText("Funcionários");
        menuConsultaFuncionario.setContentAreaFilled(false);
        menuConsultaFuncionario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultaFuncionarioActionPerformed(evt);
            }
        });
        menuConsulta.add(menuConsultaFuncionario);

        jMenuBar1.add(menuConsulta);

        menuExcluir.setText("Excluir");

        jMenuItem20.setForeground(java.awt.Color.black);
        jMenuItem20.setText("Cliente");
        jMenuItem20.setContentAreaFilled(false);
        menuExcluir.add(jMenuItem20);

        menuExcluirLocacao.setForeground(java.awt.Color.black);
        menuExcluirLocacao.setText("Locação");
        menuExcluirLocacao.setContentAreaFilled(false);
        menuExcluir.add(menuExcluirLocacao);

        menuExcluirMotorista.setForeground(java.awt.Color.black);
        menuExcluirMotorista.setText("Motorista");
        menuExcluirMotorista.setContentAreaFilled(false);
        menuExcluir.add(menuExcluirMotorista);

        menuExcluirVeiculo.setForeground(java.awt.Color.black);
        menuExcluirVeiculo.setText("Veículo");
        menuExcluirVeiculo.setContentAreaFilled(false);
        menuExcluir.add(menuExcluirVeiculo);

        menuExcluirFuncionario.setForeground(java.awt.Color.black);
        menuExcluirFuncionario.setText("Funcionários");
        menuExcluirFuncionario.setContentAreaFilled(false);
        menuExcluir.add(menuExcluirFuncionario);

        jMenuBar1.add(menuExcluir);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painelLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(332, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(painelLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(239, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void LoginBotaoLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginBotaoLoginActionPerformed
    login();



    }//GEN-LAST:event_LoginBotaoLoginActionPerformed

    private void LoginBotaoCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginBotaoCancelarActionPerformed
        painelLogin.setVisible(false);
    }//GEN-LAST:event_LoginBotaoCancelarActionPerformed

    private void menuCadastroVeiculoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastroVeiculoActionPerformed
       // ocultaPanel();
       cadastrarVeiculo.setVisible(true);

    }//GEN-LAST:event_menuCadastroVeiculoActionPerformed

    private void menuCadastroClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastroClienteActionPerformed
       // ocultaPanel();
        cadastrarVeiculo.hide();
        cadastrarCliente.setVisible(true);
      

    }//GEN-LAST:event_menuCadastroClienteActionPerformed

    private void menuCadastroFuncionarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastroFuncionarioActionPerformed
         cadastrarVeiculo.hide();
         cadastrarCliente.hide();
         cadastrarFuncionario.setVisible(true);
    }//GEN-LAST:event_menuCadastroFuncionarioActionPerformed

    private void menuCadastroDevolucaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastroDevolucaoActionPerformed
         cadastrarVeiculo.hide();
         cadastrarCliente.hide();
         cadastrarFuncionario.hide();
         cadastrarDevolucao.setVisible(true);
    }//GEN-LAST:event_menuCadastroDevolucaoActionPerformed

    private void menuCadastroLocacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastroLocacaoActionPerformed
         cadastrarVeiculo.hide();
         cadastrarCliente.hide();
         cadastrarFuncionario.hide();
         cadastrarDevolucao.hide();
         cadastrarLocacao.setVisible(true);
    }//GEN-LAST:event_menuCadastroLocacaoActionPerformed

    private void menuCadastroMotoristaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastroMotoristaActionPerformed
         cadastrarVeiculo.hide();
         cadastrarCliente.hide();
         cadastrarFuncionario.hide();
         cadastrarDevolucao.hide();
         cadastrarLocacao.hide();
         cadastrarMotorista.setVisible(true);
    }//GEN-LAST:event_menuCadastroMotoristaActionPerformed

    private void menuConsultaVeiculoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultaVeiculoActionPerformed
         cadastrarVeiculo.hide();
         cadastrarCliente.hide();
         cadastrarFuncionario.hide();
         cadastrarDevolucao.hide();
         cadastrarLocacao.hide();
         cadastrarMotorista.hide();
         consultarVeiculo.setVisible(true);
    }//GEN-LAST:event_menuConsultaVeiculoActionPerformed

    private void menuConsultaFuncionarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultaFuncionarioActionPerformed
         cadastrarVeiculo.hide();
         cadastrarCliente.hide();
         cadastrarFuncionario.hide();
         cadastrarDevolucao.hide();
         cadastrarLocacao.hide();
         cadastrarMotorista.hide();
         consultarVeiculo.hide();
         consultarFuncionario.setVisible(true);
    }//GEN-LAST:event_menuConsultaFuncionarioActionPerformed

    private void menuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSairActionPerformed

    }//GEN-LAST:event_menuSairActionPerformed

    private void menuLogarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuLogarActionPerformed
        painelLogin.setVisible(true);
        limparCampos();
    }//GEN-LAST:event_menuLogarActionPerformed

    private void menuAlterarSenhaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuAlterarSenhaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_menuAlterarSenhaActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);

            }
        });
    }

    private void inicial(){
        menuLogar.show();
        menuAlterarSenha.show();
        menuSair.show();
        menuCadastroVeiculo.hide();
        menuCadastroCliente.hide();
        menuCadastroLocacao.hide();
        menuCadastroFuncionario.hide();
        menuCadastroMotorista.hide();
        menuCadastroDevolucao.hide();
        menuConsultaLocacao.show();
        menuConsultaLocacaoAberto.show();
        menuConsultaLocacaoFinalizado.show();
        menuConsultaVeiculo.show();
        menuConsultaVeiculoDisponivel.show();
        menuConsultaVeiculoProcurados.show();
        menuConsultaVeiculoRentavel.show();
        menuConsultaCliente.show();
        menuConsultaFuncionario.show();
        jMenuItem20.hide();
        menuExcluirLocacao.hide();
        menuExcluirVeiculo.hide();
        menuExcluirMotorista.hide();
        menuExcluirFuncionario.hide();

        
        menuExcluir.hide();
        painelLogin.show();
        menuCadastro.hide();
        menuConsulta.hide();

    }
     private void login() {
         Boolean loginRealizado;
        if(LoginCampoUsuario.getText().length() == 0){
            mensagem("Por favor, digite seu nome de usuário.");
            return;
        }

        if(LoginCampoSenha.getText().length()==0){
            mensagem("Por favor, digite sua senha.");

        }
        else{

            PersistenciaUsuario pu = new PersistenciaUsuario();
            loginRealizado = pu.login(LoginCampoUsuario.getText(),LoginCampoSenha.getText());
            
            if (loginRealizado == true){
                mensagem("Usuário "+LoginCampoUsuario.getText()+ " foi logado com sucesso!");
                painelLogin.setVisible(false);
                menuLogar.hide();
                menuExcluir.show();
                menuCadastro.show();
                menuConsulta.show();
            }
            else mensagem("Usuário ou senha não existem");

                  if (LoginCampoUsuario.getText().equals("admin")){
                      administrador();
                  }
                  if (LoginCampoUsuario.getText().equals("vendedor")){
                      vendedor();
                  }
                  if (LoginCampoUsuario.getText().equals("auxiliar")){
                      auxiliar();
                  }
            }
                
             
       }
   



    private void administrador(){
        
        menuLogar.hide();
        menuAlterarSenha.show();
        menuSair.show();
        menuCadastroVeiculo.show();
        menuCadastroCliente.show();
        menuCadastroLocacao.show();
        menuCadastroFuncionario.show();
        menuCadastroMotorista.show();
        menuCadastroDevolucao.show();
        menuExcluirLocacao.show();
        menuExcluirVeiculo.show();
        menuExcluirMotorista.show();
        menuExcluirFuncionario.show();
        painelLogin.hide();
    }
    private void vendedor(){
        menuLogar.hide();
        menuAlterarSenha.show();
        menuSair.show();
        menuCadastroVeiculo.show();
        menuCadastroCliente.show();
        menuCadastroLocacao.show();
        menuCadastroMotorista.show();
        menuCadastroDevolucao.show();
        menuConsultaLocacao.show();
        menuExcluirLocacao.show();
        menuExcluirVeiculo.show();
        menuExcluirMotorista.show();
        painelLogin.hide();

    }
    private void auxiliar(){
        menuLogar.hide();
        menuAlterarSenha.show();
        menuSair.show();
        menuCadastroVeiculo.show();
        menuCadastroCliente.show();
        menuCadastroLocacao.show();
        menuCadastroMotorista.show();
        menuCadastroDevolucao.show();
        painelLogin.hide();
        menuExcluir.hide();
    }

    private void limparCampos(){
        LoginCampoUsuario.setText("");
        LoginCampoSenha.setText("");
    }

    private void mensagem(String mensagem){
        JOptionPane.showConfirmDialog(null,mensagem,"Mensagem",JOptionPane.CLOSED_OPTION);
	}

   /** public void ocultaPanel(){
        cadastrarCliente.setVisible(false);
        cadastrarVeiculo.setVisible(false);
        cadastrarFuncionario.setVisible(false);

     } **/



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton LoginBotaoCancelar;
    private javax.swing.JButton LoginBotaoLogin;
    private javax.swing.JPasswordField LoginCampoSenha;
    private javax.swing.JTextField LoginCampoUsuario;
    private javax.swing.JLabel LoginRotuloSenha;
    private javax.swing.JLabel LoginRotuloUsuario;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem20;
    private javax.swing.JMenuItem menuAlterarSenha;
    private javax.swing.JMenu menuCadastro;
    private javax.swing.JMenuItem menuCadastroCliente;
    private javax.swing.JMenuItem menuCadastroDevolucao;
    private javax.swing.JMenuItem menuCadastroFuncionario;
    private javax.swing.JMenuItem menuCadastroLocacao;
    private javax.swing.JMenuItem menuCadastroMotorista;
    private javax.swing.JMenuItem menuCadastroVeiculo;
    private javax.swing.JMenu menuConsulta;
    private javax.swing.JMenuItem menuConsultaCliente;
    private javax.swing.JMenuItem menuConsultaFuncionario;
    private javax.swing.JMenu menuConsultaLocacao;
    private javax.swing.JMenuItem menuConsultaLocacaoAberto;
    private javax.swing.JMenuItem menuConsultaLocacaoFinalizado;
    private javax.swing.JMenu menuConsultaVeiculo;
    private javax.swing.JMenuItem menuConsultaVeiculoDisponivel;
    private javax.swing.JMenuItem menuConsultaVeiculoProcurados;
    private javax.swing.JMenuItem menuConsultaVeiculoRentavel;
    private javax.swing.JMenu menuExcluir;
    private javax.swing.JMenuItem menuExcluirFuncionario;
    private javax.swing.JMenuItem menuExcluirLocacao;
    private javax.swing.JMenuItem menuExcluirMotorista;
    private javax.swing.JMenuItem menuExcluirVeiculo;
    private javax.swing.JMenuItem menuLogar;
    private javax.swing.JMenuItem menuSair;
    private javax.swing.JPanel painelLogin;
    // End of variables declaration//GEN-END:variables

}